package com.hktf.uilib.utils;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.hktf.corelib.constant.CommonConstant;
import com.hktf.corelib.constant.KEYS;
import com.hktf.corelib.utils.CommUtils;
import com.hktf.corelib.utils.MMKVUtils;
import com.hktf.uilib.R;

import java.text.SimpleDateFormat;

public class LockScreenUtil {
    public static void initLock(Context context, ImageView iv, TextView tvTime,TextView tvDate){
        int resId= MMKVUtils.getInteger(KEYS.LOCK_RESID, -1);
        ImageUtilNew.loadImageFitXY(context,resId, DisplayUtil.getMetricsWidth(context),DisplayUtil.getMetricsHeight(context),iv);

        int FONT_COLOR = MMKVUtils.getInteger(KEYS.FONT_COLOR, R.color.owner_blue);
        tvTime.setTextColor(FONT_COLOR);
        tvDate.setTextColor(FONT_COLOR);
        int FONT = MMKVUtils.getInteger(KEYS.FONT, -1);
        if(FONT!=-1){
            int[] fontResIds = CommonConstant.FONT_RES_IDS;
            CommUtils.setfont(context,tvTime,fontResIds[FONT]);
        }

        String dateFormatStr = MMKVUtils.getString(KEYS.DATE_FORMAT, "yyyy/MM/dd,E");
        tvDate.setText(new SimpleDateFormat(dateFormatStr).format(System.currentTimeMillis()));
    }
}
